<?php
// +----------------------------------------------------------------------
// | EtrolPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Author: Author: LJQ <liujiqi@etrol.com> 
// +----------------------------------------------------------------------

namespace app\admin\controller;

use app\common\controller\Admin;
use app\admin\controller\api\Logs as LogsApi;
use app\admin\controller\ajax\Library as Ajax;

/**
 * 日志管理
 * @package app\admin
 */
class Logs  extends Admin

{
	
	protected $api;
	
	public function _initialize(){
		parent::_initialize();
		$this->api = new LogsApi();
            $this->ajax= new Ajax();
	}
    /**
     * 日志列表 
     * @return mixed
     */
   public function index() {
   	if(IS_AJAX){
   		return $this->api->LogsList();
   	}

   	$userList= model('User')->column('userName','id');
   	
      $this->assign('userList',$userList);

      $type=$this->ajax->getOperatorType()->getData();
      $this->assign('type',$type);

      return $this->fetch();
 	}
 	
 	/**
 	 * 添加日志
 	 * @return View/Json
 	 */
 	public function add(){
 		if(IS_POST){
 			$data = input('post.');
 			return $this->api->add($data);
 		}
 		return $this->fetch();
 	}
 	
 	
 	/**
 	 * 清空三个月前日志
 	 * @return Json
 	 */
 	public function del(){
 		if(IS_GET){
 			return $this->api->del();
 		}
 	}
 	
 	/**
 	 * 搜索日志
 	 * @return Json
 	 */
 	public function search() {
 		if(IS_AJAX){
 			$LogsList = $this->api->search(input('start'),input('end'),input('operatorId'),input('operateType'));
      		return $LogsList;
 		}
 	}
 

}